package org.apache.flink.runtime.rest.messages.job;

import org.apache.flink.runtime.messages.webmonitor.ResourceStatusInfo;
import org.apache.flink.runtime.rest.HttpMethodWrapper;
import org.apache.flink.runtime.rest.messages.ConsumerMessageParameters;
import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
import org.apache.flink.runtime.rest.messages.MessageHeaders;
import org.apache.flink.runtime.rest.messages.RuntimeMessageHeaders;
import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;

/**
 * {@link MessageHeaders} for {@link org.apache.flink.runtime.rest.handler.job.ResourceStatusHandler}.
 */
public class ResourceStatusInfoHeaders
        implements RuntimeMessageHeaders<EmptyRequestBody, ResourceStatusInfo, ConsumerMessageParameters> {
    private static final ResourceStatusInfoHeaders INSTANCE = new ResourceStatusInfoHeaders();

    @Override
    public Class<EmptyRequestBody> getRequestClass() {
        return EmptyRequestBody.class;
    }

    @Override
    public Class<ResourceStatusInfo> getResponseClass() {
        return ResourceStatusInfo.class;
    }

    @Override
    public HttpResponseStatus getResponseStatusCode() {
        return HttpResponseStatus.OK;
    }

    @Override
    public ConsumerMessageParameters getUnresolvedMessageParameters() {
        return new ConsumerMessageParameters();
    }

    @Override
    public HttpMethodWrapper getHttpMethod() {
        return HttpMethodWrapper.GET;
    }

    @Override
    public String getTargetRestEndpointURL() {
        return "/resourcestatus";
    }

    public static ResourceStatusInfoHeaders getInstance() {
        return INSTANCE;
    }

    @Override
    public String getDescription() {
        return "Returns the current status of a resource allocation.";
    }
}
